class Admin::ChangeOrdersController < AdminController
  def index
    @change_orders = ChangeOrder.all
  end

  def new
    @change_order = ChangeOrder.new
  end

  def create
    @change_order = ChangeOrder.new(params[:change_order])
    if @change_order.save
      flash[:notice] = "Successfully created change order."
      redirect_to admin_change_orders_url
    else
      render :action => 'new'
    end
  end

  def edit
    @change_order = ChangeOrder.find(params[:id])
  end

  def update
    @change_order = ChangeOrder.find(params[:id])
    if @change_order.update_attributes(params[:change_order])
      flash[:notice] = "Successfully updated change order."
      redirect_to admin_change_orders_url
    else
      render :action => 'edit'
    end
  end

  def destroy
    @change_order = ChangeOrder.find(params[:id])
    @change_order.destroy
    flash[:notice] = "Successfully destroyed change order."
    redirect_to admin_change_orders_url
  end
end
